JDKPATH = /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
LIBPATH = ../lib/mysql-connector-java-5.1.5-bin.jar
SRC = src
OUTPUT = bin
RESOURCE = resources
MANIFEST = META-INF/MANIFEST.MF

CLASSPATH = $(JDKPATH)/lib/classes.zip:.:..:$(LIBPATH)
JAVAC = $(JDKPATH)/bin/javac -classpath $(CLASSPATH)
JAVA  = $(JDKPATH)/bin/java  -classpath $(CLASSPATH)

# Relative to ./bin directory
MAINCLASS = ui/MACS6.java
TESTCASES = ui/TestCase.java

PROGNAME = macs6.jar

PROGS = compile init

all: $(PROGS)

compile: resource
	cd $(SRC); $(JAVAC)  -d ./../$(OUTPUT) $(MAINCLASS) $(TESTCASES)

resource:
	cd $(OUTPUT); mkdir $(RESOURCE); cp ../$(SRC)/$(RESOURCE)/db.properties ./$(RESOURCE)
	
run:
	cd $(OUTPUT); $(JAVA) ui.MACS6

init:
	cd $(OUTPUT); $(JAVA) ui.TestCase

jar: compile
	cd $(OUTPUT); jar cfm $(PRONAME) $(MANIFEST) ./*.*

clean:
	cd $(OUTPUT); find . -name "*.class" -exec rm {} \;
